<template>
  <div>
    <div class="div1">
      <div class="imgb">
        <router-link to="/"
          ><img src="../assets/imgs/xiaomilogo.png" alt="" class="imga"
        /></router-link>
      </div>
      <div>
        <el-button type="text">小米商城</el-button>
        <el-button type="text">MUI</el-button>
        <el-button type="text">云服务</el-button>
        <el-button type="text">协议规则</el-button>
        <el-button type="text">协议规则</el-button>
      </div>
    </div>
    <el-divider class="fenge"></el-divider>
    <div class="div2">
      <h3 class="h3">{{ showcard.Cname }}</h3>
      <el-button class="butten1" @click="GetIndex3(showcard.Cid)"
        >点击立即购买</el-button
      >
    </div>
    <div class="">
      <img :src="showcard.Cimgs" alt="" class="imgc" />
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showcard: {},
      Username: "",
    };
  },

  methods: {
    showcomm() {
      this.$axios
        .get(
          "http://localhost:16673/api/Commod/ShowCommodl?Cid=" +
            this.$route.query.Cid
        )
        .then((res) => {
          this.showcard = res.data[0];
        });
    },
    GetIndex3(Cid) {
      
      //判断是否登录
      if (this.Username != null) {
        this.$router.push('/Index3?Cid='+Cid)
      } else {
         this.$confirm('请先登录', '提示', {
          confirmButtonText: '登录',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$router.push("/Load");
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消登录'
          });
        });
      }
    },
  },
  created() {
    this.showcomm();
    this.Username = sessionStorage.getItem("Username");
  },
};
</script>

<style scoped>
.div1 {
  margin: 0 auto;
  width: 1220px;
  height: 100px;
  margin-top: 8px;
}
.div2 {
  width: 1545px;
  margin: 0 auto;
  margin-left: -18px;
  height: 45px;
  box-shadow: 0 20px 20px 0px rgb(0, 0, 0, 0.1);
  /* 0, 0, 0, 0.1 */
  margin-top: -15px;
}
.imgb {
  float: left;
  margin-top: 5px;
}
.el-button {
  float: left;
  color: black;
  margin-top: 25px;
  font-size: 20px;
  margin-left: 80px;
}
.imgc {
  width: 1530px;
  margin: 0 auto;
  margin-left: -8px;
  margin-top: 20px;
}
.fenge {
  margin-top: 0px;
}
.butten1 {
  font-size: 15px;
  background-color: #f06000;
  float: right;
  margin-top: 0px;
  color: white;
  margin-right: 50px;
}
.h3 {
  margin-top: 0px;
  float: left;
  margin-left: 30px;
}
.imga {
  float: left;
  width: 80px;
}
</style>
